/**
 * 功能描述 表单
 */

define(function (require, exports, module){
	var Form = require("form");
	var aw = require("ajaxwrapper");
	var Dialog = require("dialog");
	var store =require("store");
	var activeUser = store.get("user");
	var Date = require("date");
	var enmu = require("enums");
	var year = moment().format('YYYY');
	var instance = {
		initComponent: function (params,widget){
			
			
			var years = [];
			year = parseInt(year);
			
			for(var i=0;i<3;i++){
				years.unshift({
					key: moment().year(year-i).startOf("year").valueOf(),
					value: parseInt(year)-i
				});
				years.push({
					key: moment().year(year+i+1).startOf("year").valueOf(),
					value: parseInt(year)+ i+1
				});
			}
			
			var form=new Form({
				parentNode:".J-form",
				show:false,
				model:{
					id:"plan",
					defaultButton:false,
					layout : "3_1",
					items:[{
						name:"pkPlan",
						type:"hidden"
					},{
						name:"organization",
					    type:"hidden",
					    defaultValue:activeUser.organization.pkOrganization
					},{
						name:"status",
						type:"hidden",
						defaultValue:"UnRelease"
					},{
						name:"version",
						type:"hidden",
						defaultValue:"0"
					},{
						name:"verNumber",
						label:"版本号",
						validate:["required"]
					},{
						name:"year",
						label:"年度",
						type:"select",
						options: years,
						defaultValue:moment().startOf("years").valueOf(),
						validate:["required"]
					},{
						name:"planTitle",
						label:"计划名称",
						validate:["required"]
					},{
						name:"editor",
						label:"编制人",
						defaultValue:activeUser.name,
					},{
						name:"editorDate",
						label:"编制日期",
						type:"date",
						mode:"YYYY-MM-DD",
					},{
						name:"introduction",
						label:"年度计划介绍",
						type:"textarea",
						"break":true
					},{
						name:"explanation",
						label:"其他事项说明",
						type:"textarea",
						"break":true
					}]
				}
			});
			widget.set("form", form);
		}
	};
	module.exports = instance;
});